﻿//https://leetcode.cn/problems/majority-element/?envType=study-plan-v2&envId=top-100-liked

class Solution {
public:
    int majorityElement(vector<int>& nums)
    {
        sort(nums.begin(), nums.end());
        return  nums[nums.size() / 2];
    }
};

//https://leetcode.cn/problems/sort-colors/?envType=study-plan-v2&envId=top-100-liked

class Solution {
public:
    void sortColors(vector<int>& nums) {
        int i = 0, left = -1, right = nums.size();
        while (i < right)
        {
            if (nums[i] < 1) swap(nums[++left], nums[i++]);
            else if (nums[i] == 1) i++;
            else swap(nums[--right], nums[i]);
        }

    }
};